package basic

import (
	"fmt"
)

func myFunction(a, b int) (int, int) {
	return a + b, a - b
}

type Speak interface {
	Speak() string
}

type Walker interface {
	Walk() string
}

type Animal interface {
	Speak
	Walker
}

type Dog struct {
	Name string
}

func (d Dog) Speak() string {
	return "Speak"
}

// Walk 禁止函数内联汇编
//
//go:noinline
func (d Dog) Walk() string {
	return "Walk"
}

type TestStruct struct{}

func NilOrNot(v interface{}) bool {
	return v == nil
}

func BasicInterfaceMain() {
	myFunction(66, 67)

	dog := Dog{"小花"}
	dog.Walk()
	dog.Speak()
	var animal Animal
	animal = dog

	switch animal.(type) {
	case Dog:
		iDog := animal.(Dog)
		iDog.Speak()
		fmt.Println(iDog.Speak(), iDog.Walk())
	}

	//fmt.Println(animal.Speak(), animal.Walk())

	// interface test
	//var s *TestStruct
	//fmt.Println(s == nil)    // true
	//fmt.Println(NilOrNot(s)) // false

}
